package com.tech.cloudapp.controller;


import com.tech.cloudapp.biz.service.IBQuestionPaperService;
import com.tech.cloudapp.db.entity.QuestionPaper;
import com.tech.cloudapp.dto.PageDTO;
import com.tech.cloudapp.model.CommonResponseDO;
import com.tech.cloudapp.po.QuestionPaperPO;
import com.tech.cloudapp.util.BeanCopyUtils;
import com.tech.cloudapp.util.ValidatorUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 试卷信息表 前端控制器
 * </p>
 *
 * @author mojianyou
 * @since 2025-03-23
 */
@RestController
@RequestMapping("/question-paper")
public class QuestionPaperController {

    @Autowired
    private IBQuestionPaperService bQuestionPaperServiceImpl;


    @PostMapping("list")
    public CommonResponseDO list(@RequestBody QuestionPaperPO questionPaperPO)
    {
        ValidatorUtils.validate(questionPaperPO);
        QuestionPaper questionPaper = BeanCopyUtils.copyBean(questionPaperPO,QuestionPaper.class);
        List<QuestionPaper> list = bQuestionPaperServiceImpl.list(questionPaper);
        return CommonResponseDO.success(list);
    }

    @PostMapping("page")
    public CommonResponseDO page(@RequestBody QuestionPaperPO questionPaperPO)
    {
        ValidatorUtils.validate(questionPaperPO);
       // QuestionPaper questionPaper = BeanCopyUtils.copyBean(questionPaperPO,QuestionPaper.class);
        PageDTO page = bQuestionPaperServiceImpl.page(questionPaperPO);
        return CommonResponseDO.success(page);
    }

}

